load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "sysutil",
    srcs = [
        "acl_unix.go",
        "acl_windows.go",
        "aclinfo.go",
        "large_file.go",
        "large_file_linux.go",
        "large_file_nonlinux.go",
        "socket.go",
        "socket_darwin.go",
        "socket_linux.go",
        "socket_stub.go",
        "sysutil.go",
        "sysutil_unix.go",
        "sysutil_windows.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/util/sysutil",
    visibility = ["//visibility:public"],
    deps = [
        "@com_github_cockroachdb_errors//:errors",
    ] + select({
        "@io_bazel_rules_go//go/platform:aix": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:android": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:darwin": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:dragonfly": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:freebsd": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:illumos": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:ios": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:js": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:linux": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:netbsd": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:openbsd": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:plan9": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:solaris": [
            "@org_golang_x_sys//unix",
        ],
        "//conditions:default": [],
    }),
)

go_test(
    name = "sysutil_test",
    size = "small",
    srcs = [
        "acl_unix_test.go",
        "large_file_test.go",
        "sysutil_test.go",
        "sysutil_unix_test.go",
    ],
    embed = [":sysutil"],
    deps = [
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_stretchr_testify//require",
    ] + select({
        "@io_bazel_rules_go//go/platform:aix": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:android": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:darwin": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:dragonfly": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:freebsd": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:illumos": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:ios": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:js": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:linux": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:netbsd": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:openbsd": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:plan9": [
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:solaris": [
            "@com_github_stretchr_testify//assert",
            "@org_golang_x_sys//unix",
        ],
        "//conditions:default": [],
    }),
)
